home *** CD-ROM | disk | FTP | other *** search
/ 3D Game Programming All in One / 3D Game Programming All in One Disc.iso / 3D2E / demo / server / scripts / player.cs < prev    next >
Encoding:
Text File  |  2006-09-23  |  24.8 KB  |  965 lines

  1. //-----------------------------------------------------------------------------
  2. // Torque Game Engine 
  3. // Copyright (C) GarageGames.com, Inc.
  4. //-----------------------------------------------------------------------------
  5.  
  6. // Load dts shapes and merge animations
  7. exec("~/data/shapes/player/player.cs");
  8.  
  9. // Timeouts for corpse deletion.
  10. $CorpseTimeoutValue = 22 * 1000;
  11.  
  12. // Damage Rate for entering Liquid
  13. $DamageLava       = 0.01;
  14. $DamageHotLava    = 0.01;
  15. $DamageCrustyLava = 0.01;
  16.  
  17. //
  18. $PlayerDeathAnim::TorsoFrontFallForward = 1;
  19. $PlayerDeathAnim::TorsoFrontFallBack = 2;
  20. $PlayerDeathAnim::TorsoBackFallForward = 3;
  21. $PlayerDeathAnim::TorsoLeftSpinDeath = 4;
  22. $PlayerDeathAnim::TorsoRightSpinDeath = 5;
  23. $PlayerDeathAnim::LegsLeftGimp = 6;
  24. $PlayerDeathAnim::LegsRightGimp = 7;
  25. $PlayerDeathAnim::TorsoBackFallForward = 8;
  26. $PlayerDeathAnim::HeadFrontDirect = 9;
  27. $PlayerDeathAnim::HeadBackFallForward = 10;
  28. $PlayerDeathAnim::ExplosionBlowBack = 11;
  29.  
  30.  
  31. //----------------------------------------------------------------------------
  32. // Player Audio Profiles
  33. //----------------------------------------------------------------------------
  34.  
  35. //----------------------------------------------------------------------------
  36.  
  37. datablock AudioProfile(DeathCrySound)
  38. {
  39.    fileName = "~/data/sound/orc_death.ogg";
  40.    description = AudioClose3d;
  41.    preload = true;
  42. };
  43.  
  44. datablock AudioProfile(PainCrySound)
  45. {
  46.    fileName = "~/data/sound/orc_pain.ogg";
  47.    description = AudioClose3d;
  48.    preload = true;
  49. };
  50.  
  51.  
  52. //----------------------------------------------------------------------------
  53.  
  54. datablock AudioProfile(FootLightSoftSound)
  55. {
  56.    filename    = "~/data/sound/footstep_soft.ogg";
  57.    description = AudioClosest3d;
  58.    preload = true;
  59. };
  60.  
  61. datablock AudioProfile(FootLightHardSound)
  62. {
  63.    filename    = "~/data/sound/footstep_hard.ogg";
  64.    description = AudioClose3d;
  65.    preload = true;
  66. };
  67.  
  68. datablock AudioProfile(FootLightMetalSound)
  69. {
  70.    filename    = "~/data/sound/footstep_hard.ogg";
  71.    description = AudioClose3d;
  72.    preload = true;
  73. };
  74.  
  75. datablock AudioProfile(FootLightSnowSound)
  76. {
  77.    filename    = "~/data/sound/footstep_soft.ogg";
  78.    description = AudioClosest3d;
  79.    preload = true;
  80. };
  81.  
  82. datablock AudioProfile(FootLightShallowSplashSound)
  83. {
  84.    filename    = "~/data/sound/footstep_water.ogg";
  85.    description = AudioClose3d;
  86.    preload = true;
  87. };
  88.  
  89. datablock AudioProfile(FootLightWadingSound)
  90. {
  91.    filename    = "~/data/sound/footstep_water.ogg";
  92.    description = AudioClose3d;
  93.    preload = true;
  94. };
  95.  
  96. datablock AudioProfile(FootLightUnderwaterSound)
  97. {
  98.    filename    = "~/data/sound/footstep_water.ogg";
  99.    description = AudioClosest3d;
  100.    preload = true;
  101. };
  102.  
  103. datablock AudioProfile(FootLightBubblesSound)
  104. {
  105.    filename    = "~/data/sound/replaceme.ogg";
  106.    description = AudioClose3d;
  107.    preload = true;
  108. };
  109.  
  110. datablock AudioProfile(ArmorMoveBubblesSound)
  111. {
  112.    filename    = "~/data/sound/replaceme.ogg";
  113.    description = AudioCloseLooping3d;
  114.    preload = true;
  115. };
  116.  
  117. datablock AudioProfile(WaterBreathMaleSound)
  118. {
  119.    filename    = "~/data/sound/replaceme.ogg";
  120.    description = AudioClosestLooping3d;
  121.    preload = true;
  122. };
  123.  
  124.  
  125. //----------------------------------------------------------------------------
  126.  
  127. datablock AudioProfile(ImpactLightSoftSound)
  128. {
  129.    filename    = "~/data/sound/replaceme.ogg";
  130.    description = AudioClose3d;
  131.    preload = true;
  132.    effect = ImpactSoftEffect;
  133. };
  134.  
  135. datablock AudioProfile(ImpactLightHardSound)
  136. {
  137.    filename    = "~/data/sound/replaceme.ogg";
  138.    description = AudioClose3d;
  139.    preload = true;
  140.    effect = ImpactHardEffect;
  141. };
  142.  
  143. datablock AudioProfile(ImpactLightMetalSound)
  144. {
  145.    filename    = "~/data/sound/replaceme.ogg";
  146.    description = AudioClose3d;
  147.    preload = true;
  148.    effect = ImpactMetalEffect;
  149. };
  150.  
  151. datablock AudioProfile(ImpactLightSnowSound)
  152. {
  153.    filename    = "~/data/sound/replaceme.ogg";
  154.    description = AudioClosest3d;
  155.    preload = true;
  156.    effect = ImpactSnowEffect;
  157. };
  158.  
  159. datablock AudioProfile(ImpactLightWaterEasySound)
  160. {
  161.    filename    = "~/data/sound/replaceme.ogg";
  162.    description = AudioClose3d;
  163.    preload = true;
  164. };
  165.  
  166. datablock AudioProfile(ImpactLightWaterMediumSound)
  167. {
  168.    filename    = "~/data/sound/replaceme.ogg";
  169.    description = AudioClose3d;
  170.    preload = true;
  171. };
  172.  
  173. datablock AudioProfile(ImpactLightWaterHardSound)
  174. {
  175.    filename    = "~/data/sound/replaceme.ogg";
  176.    description = AudioDefault3d;
  177.    preload = true;
  178. };
  179.  
  180. datablock AudioProfile(ExitingWaterLightSound)
  181. {
  182.    filename    = "~/data/sound/replaceme.ogg";
  183.    description = AudioClose3d;
  184.    preload = true;
  185. };
  186.  
  187.  
  188. //----------------------------------------------------------------------------
  189. // Splash
  190. //----------------------------------------------------------------------------
  191.  
  192. datablock ParticleData(PlayerSplashMist)
  193. {
  194.    dragCoefficient      = 2.0;
  195.    gravityCoefficient   = -0.05;
  196.    inheritedVelFactor   = 0.0;
  197.    constantAcceleration = 0.0;
  198.    lifetimeMS           = 400;
  199.    lifetimeVarianceMS   = 100;
  200.    useInvAlpha          = false;
  201.    spinRandomMin        = -90.0;
  202.    spinRandomMax        = 500.0;
  203.    textureName          = "~/data/shapes/player/splash";
  204.    colors[0]     = "0.7 0.8 1.0 1.0";
  205.    colors[1]     = "0.7 0.8 1.0 0.5";
  206.    colors[2]     = "0.7 0.8 1.0 0.0";
  207.    sizes[0]      = 0.5;
  208.    sizes[1]      = 0.5;
  209.    sizes[2]      = 0.8;
  210.    times[0]      = 0.0;
  211.    times[1]      = 0.5;
  212.    times[2]      = 1.0;
  213. };
  214.  
  215. datablock ParticleEmitterData(PlayerSplashMistEmitter)
  216. {
  217.    ejectionPeriodMS = 5;
  218.    periodVarianceMS = 0;
  219.    ejectionVelocity = 3.0;
  220.    velocityVariance = 2.0;
  221.    ejectionOffset   = 0.0;
  222.    thetaMin         = 85;
  223.    thetaMax         = 85;
  224.    phiReferenceVel  = 0;
  225.    phiVariance      = 360;
  226.    overrideAdvance = false;
  227.    lifetimeMS       = 250;
  228.    particles = "PlayerSplashMist";
  229. };
  230.  
  231.  
  232. datablock ParticleData(PlayerBubbleParticle)
  233. {
  234.    dragCoefficient      = 0.0;
  235.    gravityCoefficient   = -0.50;
  236.    inheritedVelFactor   = 0.0;
  237.    constantAcceleration = 0.0;
  238.    lifetimeMS           = 400;
  239.    lifetimeVarianceMS   = 100;
  240.    useInvAlpha          = false;
  241.    textureName          = "~/data/shapes/player/splash";
  242.    colors[0]     = "0.7 0.8 1.0 0.4";
  243.    colors[1]     = "0.7 0.8 1.0 0.4";
  244.    colors[2]     = "0.7 0.8 1.0 0.0";
  245.    sizes[0]      = 0.1;
  246.    sizes[1]      = 0.3;
  247.    sizes[2]      = 0.3;
  248.    times[0]      = 0.0;
  249.    times[1]      = 0.5;
  250.    times[2]      = 1.0;
  251. };
  252.  
  253. datablock ParticleEmitterData(PlayerBubbleEmitter)
  254. {
  255.    ejectionPeriodMS = 1;
  256.    periodVarianceMS = 0;
  257.    ejectionVelocity = 2.0;
  258.    ejectionOffset   = 0.5;
  259.    velocityVariance = 0.5;
  260.    thetaMin         = 0;
  261.    thetaMax         = 80;
  262.    phiReferenceVel  = 0;
  263.    phiVariance      = 360;
  264.    overrideAdvance = false;
  265.    particles = "PlayerBubbleParticle";
  266. };
  267.  
  268. datablock ParticleData(PlayerFoamParticle)
  269. {
  270.    dragCoefficient      = 2.0;
  271.    gravityCoefficient   = -0.05;
  272.    inheritedVelFactor   = 0.0;
  273.    constantAcceleration = 0.0;
  274.    lifetimeMS           = 400;
  275.    lifetimeVarianceMS   = 100;
  276.    useInvAlpha          = false;
  277.    spinRandomMin        = -90.0;
  278.    spinRandomMax        = 500.0;
  279.    textureName          = "~/data/shapes/player/splash";
  280.    colors[0]     = "0.7 0.8 1.0 0.20";
  281.    colors[1]     = "0.7 0.8 1.0 0.20";
  282.    colors[2]     = "0.7 0.8 1.0 0.00";
  283.    sizes[0]      = 0.2;
  284.    sizes[1]      = 0.4;
  285.    sizes[2]      = 1.6;
  286.    times[0]      = 0.0;
  287.    times[1]      = 0.5;
  288.    times[2]      = 1.0;
  289. };
  290.  
  291. datablock ParticleEmitterData(PlayerFoamEmitter)
  292. {
  293.    ejectionPeriodMS = 10;
  294.    periodVarianceMS = 0;
  295.    ejectionVelocity = 3.0;
  296.    velocityVariance = 1.0;
  297.    ejectionOffset   = 0.0;
  298.    thetaMin         = 85;
  299.    thetaMax         = 85;
  300.    phiReferenceVel  = 0;
  301.    phiVariance      = 360;
  302.    overrideAdvance = false;
  303.    particles = "PlayerFoamParticle";
  304. };
  305.  
  306.  
  307. datablock ParticleData( PlayerFoamDropletsParticle )
  308. {
  309.    dragCoefficient      = 1;
  310.    gravityCoefficient   = 0.2;
  311.    inheritedVelFactor   = 0.2;
  312.    constantAcceleration = -0.0;
  313.    lifetimeMS           = 600;
  314.    lifetimeVarianceMS   = 0;
  315.    textureName          = "~/data/shapes/player/splash";
  316.    colors[0]     = "0.7 0.8 1.0 1.0";
  317.    colors[1]     = "0.7 0.8 1.0 0.5";
  318.    colors[2]     = "0.7 0.8 1.0 0.0";
  319.    sizes[0]      = 0.8;
  320.    sizes[1]      = 0.3;
  321.    sizes[2]      = 0.0;
  322.    times[0]      = 0.0;
  323.    times[1]      = 0.5;
  324.    times[2]      = 1.0;
  325. };
  326.  
  327. datablock ParticleEmitterData( PlayerFoamDropletsEmitter )
  328. {
  329.    ejectionPeriodMS = 7;
  330.    periodVarianceMS = 0;
  331.    ejectionVelocity = 2;
  332.    velocityVariance = 1.0;
  333.    ejectionOffset   = 0.0;
  334.    thetaMin         = 60;
  335.    thetaMax         = 80;
  336.    phiReferenceVel  = 0;
  337.    phiVariance      = 360;
  338.    overrideAdvance = false;
  339.    orientParticles  = true;
  340.    particles = "PlayerFoamDropletsParticle";
  341. };
  342.  
  343.  
  344. datablock ParticleData( PlayerSplashParticle )
  345. {
  346.    dragCoefficient      = 1;
  347.    gravityCoefficient   = 0.2;
  348.    inheritedVelFactor   = 0.2;
  349.    constantAcceleration = -0.0;
  350.    lifetimeMS           = 600;
  351.    lifetimeVarianceMS   = 0;
  352.    colors[0]     = "0.7 0.8 1.0 1.0";
  353.    colors[1]     = "0.7 0.8 1.0 0.5";
  354.    colors[2]     = "0.7 0.8 1.0 0.0";
  355.    sizes[0]      = 0.5;
  356.    sizes[1]      = 0.5;
  357.    sizes[2]      = 0.5;
  358.    times[0]      = 0.0;
  359.    times[1]      = 0.5;
  360.    times[2]      = 1.0;
  361. };
  362.  
  363. datablock ParticleEmitterData( PlayerSplashEmitter )
  364. {
  365.    ejectionPeriodMS = 1;
  366.    periodVarianceMS = 0;
  367.    ejectionVelocity = 3;
  368.    velocityVariance = 1.0;
  369.    ejectionOffset   = 0.0;
  370.    thetaMin         = 60;
  371.    thetaMax         = 80;
  372.    phiReferenceVel  = 0;
  373.    phiVariance      = 360;
  374.    overrideAdvance = false;
  375.    orientParticles  = true;
  376.    lifetimeMS       = 100;
  377.    particles = "PlayerSplashParticle";
  378. };
  379.  
  380. datablock SplashData(PlayerSplash)
  381. {
  382.    numSegments = 15;
  383.    ejectionFreq = 15;
  384.    ejectionAngle = 40;
  385.    ringLifetime = 0.5;
  386.    lifetimeMS = 300;
  387.    velocity = 4.0;
  388.    startRadius = 0.0;
  389.    acceleration = -3.0;
  390.    texWrap = 5.0;
  391.  
  392.    texture = "~/data/shapes/player/splash";
  393.  
  394.    emitter[0] = PlayerSplashEmitter;
  395.    emitter[1] = PlayerSplashMistEmitter;
  396.  
  397.    colors[0] = "0.7 0.8 1.0 0.0";
  398.    colors[1] = "0.7 0.8 1.0 0.3";
  399.    colors[2] = "0.7 0.8 1.0 0.7";
  400.    colors[3] = "0.7 0.8 1.0 0.0";
  401.    times[0] = 0.0;
  402.    times[1] = 0.4;
  403.    times[2] = 0.8;
  404.    times[3] = 1.0;
  405. };
  406.  
  407.  
  408. //----------------------------------------------------------------------------
  409. // Foot puffs
  410. //----------------------------------------------------------------------------
  411.  
  412. datablock ParticleData(LightPuff)
  413. {
  414.    dragCoefficient      = 2.0;
  415.    gravityCoefficient   = -0.01;
  416.    inheritedVelFactor   = 0.6;
  417.    constantAcceleration = 0.0;
  418.    lifetimeMS           = 800;
  419.    lifetimeVarianceMS   = 100;
  420.    useInvAlpha          = true;
  421.    spinRandomMin        = -35.0;
  422.    spinRandomMax        = 35.0;
  423.    colors[0]     = "1.0 1.0 1.0 1.0";
  424.    colors[1]     = "1.0 1.0 1.0 0.0";
  425.    sizes[0]      = 0.1;
  426.    sizes[1]      = 0.8;
  427.    times[0]      = 0.3;
  428.    times[1]      = 1.0;
  429. };
  430.  
  431. datablock ParticleEmitterData(LightPuffEmitter)
  432. {
  433.    ejectionPeriodMS = 35;
  434.    periodVarianceMS = 10;
  435.    ejectionVelocity = 0.2;
  436.    velocityVariance = 0.1;
  437.    ejectionOffset   = 0.0;
  438.    thetaMin         = 20;
  439.    thetaMax         = 60;
  440.    phiReferenceVel  = 0;
  441.    phiVariance      = 360;
  442.    overrideAdvance = false;
  443.    useEmitterColors = true;
  444.    particles = "LightPuff";
  445. };
  446.  
  447. //----------------------------------------------------------------------------
  448. // Liftoff dust
  449. //----------------------------------------------------------------------------
  450.  
  451. datablock ParticleData(LiftoffDust)
  452. {
  453.    dragCoefficient      = 1.0;
  454.    gravityCoefficient   = -0.01;
  455.    inheritedVelFactor   = 0.0;
  456.    constantAcceleration = 0.0;
  457.    lifetimeMS           = 1000;
  458.    lifetimeVarianceMS   = 100;
  459.    useInvAlpha          = true;
  460.    spinRandomMin        = -90.0;
  461.    spinRandomMax        = 500.0;
  462.    colors[0]     = "1.0 1.0 1.0 1.0";
  463.    sizes[0]      = 1.0;
  464.    times[0]      = 1.0;
  465. };
  466.  
  467. datablock ParticleEmitterData(LiftoffDustEmitter)
  468. {
  469.    ejectionPeriodMS = 5;
  470.    periodVarianceMS = 0;
  471.    ejectionVelocity = 2.0;
  472.    velocityVariance = 0.0;
  473.    ejectionOffset   = 0.0;
  474.    thetaMin         = 90;
  475.    thetaMax         = 90;
  476.    phiReferenceVel  = 0;
  477.    phiVariance      = 360;
  478.    overrideAdvance = false;
  479.    useEmitterColors = true;
  480.    particles = "LiftoffDust";
  481. };
  482.  
  483.  
  484. //----------------------------------------------------------------------------
  485.  
  486. datablock DecalData(PlayerFootprint)
  487. {
  488.    sizeX       = 0.25;
  489.    sizeY       = 0.25;
  490.    textureName = "~/data/shapes/player/footprint";
  491. };
  492.  
  493. datablock DebrisData( PlayerDebris )
  494. {
  495.    explodeOnMaxBounce = false;
  496.  
  497.    elasticity = 0.15;
  498.    friction = 0.5;
  499.  
  500.    lifetime = 4.0;
  501.    lifetimeVariance = 0.0;
  502.  
  503.    minSpinSpeed = 40;
  504.    maxSpinSpeed = 600;
  505.  
  506.    numBounces = 5;
  507.    bounceVariance = 0;
  508.  
  509.    staticOnMaxBounce = true;
  510.    gravModifier = 1.0;
  511.  
  512.    useRadiusMass = true;
  513.    baseRadius = 1;
  514.  
  515.    velocity = 20.0;
  516.    velocityVariance = 12.0;
  517. };             
  518.  
  519. datablock PlayerData(PlayerBody)
  520. {
  521.    renderFirstPerson = false;
  522.    emap = true;
  523.    
  524.    className = Armor;
  525.    shapeFile = "~/data/shapes/player/player.dts";
  526.    cameraMaxDist = 3;
  527.    computeCRC = true;
  528.   
  529.    canObserve = true;
  530.    cmdCategory = "Clients";
  531.  
  532.    cameraDefaultFov = 90.0;
  533.    cameraMinFov = 5.0;
  534.    cameraMaxFov = 120.0;
  535.    
  536.    debrisShapeName = "~/data/shapes/player/debris_player.dts";
  537.    debris = playerDebris;
  538.  
  539.    aiAvoidThis = true;
  540.  
  541.    minLookAngle = -1.4;
  542.    maxLookAngle = 1.4;
  543.    maxFreelookAngle = 3.0;
  544.  
  545.    mass = 90;
  546.    drag = 0.3;
  547.    maxdrag = 0.4;
  548.    density = 10;
  549.    maxDamage = 100;
  550.    maxEnergy =  60;
  551.    repairRate = 0.33;
  552.    energyPerDamagePoint = 75.0;
  553.  
  554.    rechargeRate = 0.256;
  555.  
  556.    runForce = 48 * 90;
  557.    runEnergyDrain = 0;
  558.    minRunEnergy = 0;
  559.    maxForwardSpeed = 14;
  560.    maxBackwardSpeed = 13;
  561.    maxSideSpeed = 13;
  562.  
  563.    maxUnderwaterForwardSpeed = 8.4;
  564.    maxUnderwaterBackwardSpeed = 7.8;
  565.    maxUnderwaterSideSpeed = 7.8;
  566.  
  567.    jumpForce = 8.3 * 90;
  568.    jumpEnergyDrain = 0;
  569.    minJumpEnergy = 0;
  570.    jumpDelay = 15;
  571.  
  572.    recoverDelay = 9;
  573.    recoverRunForceScale = 1.2;
  574.  
  575.    minImpactSpeed = 45;
  576.    speedDamageScale = 0.4;
  577.  
  578.    boundingBox = "1.2 1.2 2.3";
  579.    pickupRadius = 0.75;
  580.    
  581.    // Damage location details
  582.    boxNormalHeadPercentage       = 0.83;
  583.    boxNormalTorsoPercentage      = 0.49;
  584.    boxHeadLeftPercentage         = 0;
  585.    boxHeadRightPercentage        = 1;
  586.    boxHeadBackPercentage         = 0;
  587.    boxHeadFrontPercentage        = 1;
  588.  
  589.    // Foot Prints
  590.    decalData   = PlayerFootprint;
  591.    decalOffset = 0.25;
  592.    
  593.    footPuffEmitter = LightPuffEmitter;
  594.    footPuffNumParts = 10;
  595.    footPuffRadius = 0.25;
  596.  
  597.    dustEmitter = LiftoffDustEmitter;
  598.  
  599.    splash = PlayerSplash;
  600.    splashVelocity = 4.0;
  601.    splashAngle = 67.0;
  602.    splashFreqMod = 300.0;
  603.    splashVelEpsilon = 0.60;
  604.    bubbleEmitTime = 0.4;
  605.    splashEmitter[0] = PlayerFoamDropletsEmitter;
  606.    splashEmitter[1] = PlayerFoamEmitter;
  607.    splashEmitter[2] = PlayerBubbleEmitter;
  608.    mediumSplashSoundVelocity = 10.0;   
  609.    hardSplashSoundVelocity = 20.0;   
  610.    exitSplashSoundVelocity = 5.0;
  611.  
  612.    // Controls over slope of runnable/jumpable surfaces
  613.    runSurfaceAngle  = 70;
  614.    jumpSurfaceAngle = 80;
  615.  
  616.    minJumpSpeed = 20;
  617.    maxJumpSpeed = 30;
  618.  
  619.    horizMaxSpeed = 68;
  620.    horizResistSpeed = 33;
  621.    horizResistFactor = 0.35;
  622.  
  623.    upMaxSpeed = 80;
  624.    upResistSpeed = 25;
  625.    upResistFactor = 0.3;
  626.    
  627.    footstepSplashHeight = 0.35;
  628.  
  629.    //NOTE:  some sounds commented out until wav's are available
  630.  
  631.    // Footstep Sounds
  632.    FootSoftSound        = FootLightSoftSound;
  633.    FootHardSound        = FootLightHardSound;
  634.    FootMetalSound       = FootLightMetalSound;
  635.    FootSnowSound        = FootLightSnowSound;
  636.    FootShallowSound     = FootLightShallowSplashSound;
  637.    FootWadingSound      = FootLightWadingSound;
  638.    FootUnderwaterSound  = FootLightUnderwaterSound;
  639.  
  640.    //FootBubblesSound     = FootLightBubblesSound;
  641.    //movingBubblesSound   = ArmorMoveBubblesSound;
  642.    //waterBreathSound     = WaterBreathMaleSound;
  643.  
  644.    //impactSoftSound      = ImpactLightSoftSound;
  645.    //impactHardSound      = ImpactLightHardSound;
  646.    //impactMetalSound     = ImpactLightMetalSound;
  647.    //impactSnowSound      = ImpactLightSnowSound;
  648.    
  649.    //impactWaterEasy      = ImpactLightWaterEasySound;
  650.    //impactWaterMedium    = ImpactLightWaterMediumSound;
  651.    //impactWaterHard      = ImpactLightWaterHardSound;
  652.    
  653.    groundImpactMinSpeed    = 10.0;
  654.    groundImpactShakeFreq   = "4.0 4.0 4.0";
  655.    groundImpactShakeAmp    = "1.0 1.0 1.0";
  656.    groundImpactShakeDuration = 0.8;
  657.    groundImpactShakeFalloff = 10.0;
  658.    
  659.    //exitingWater         = ExitingWaterLightSound;
  660.    
  661.    observeParameters = "0.5 4.5 4.5";
  662.  
  663.    // Allowable Inventory Items
  664.    maxInv[BulletAmmo] = 20;
  665.    maxInv[HealthKit] = 1;
  666.    maxInv[RifleAmmo] = 100;
  667.    maxInv[CrossbowAmmo] = 50;
  668.    maxInv[Crossbow] = 1;
  669.    maxInv[Rifle] = 1;
  670. };
  671.  
  672.  
  673. //----------------------------------------------------------------------------
  674. // Armor Datablock methods
  675. //----------------------------------------------------------------------------
  676.  
  677. //----------------------------------------------------------------------------
  678.  
  679. function Armor::onAdd(%this,%obj)
  680. {
  681.    // Vehicle timeout
  682.    %obj.mountVehicle = true;
  683.  
  684.    // Default dynamic armor stats
  685.    %obj.setRechargeRate(%this.rechargeRate);
  686.    %obj.setRepairRate(0);
  687. }
  688.  
  689. function Armor::onRemove(%this, %obj)
  690. {
  691.    if (%obj.client.player == %obj)
  692.       %obj.client.player = 0;
  693. }
  694.  
  695. function Armor::onNewDataBlock(%this,%obj)
  696. {
  697. }
  698.  
  699.  
  700. //----------------------------------------------------------------------------
  701.  
  702. function Armor::onMount(%this,%obj,%vehicle,%node)
  703. {
  704.    if (%node == 0)  {
  705.       %obj.setTransform("0 0 0 0 0 1 0");
  706.       %obj.setActionThread(%vehicle.getDatablock().mountPose[%node],true,true);
  707.       %obj.lastWeapon = %obj.getMountedImage($WeaponSlot);
  708.  
  709.       %obj.unmountImage($WeaponSlot);
  710.       %obj.setControlObject(%vehicle);
  711.    }
  712. }
  713.  
  714. function Armor::onUnmount( %this, %obj, %vehicle, %node )
  715. {
  716.    if (%node == 0)
  717.       %obj.mountImage(%obj.lastWeapon, $WeaponSlot);
  718. }
  719.  
  720. function Armor::doDismount(%this, %obj, %forced)
  721. {
  722.    // This function is called by player.cc when the jump trigger
  723.    // is true while mounted
  724.    if (!%obj.isMounted())
  725.       return;
  726.  
  727.    // Position above dismount point
  728.    %pos    = getWords(%obj.getTransform(), 0, 2);
  729.    %oldPos = %pos;
  730.    %vec[0] = " 0  0  1";
  731.    %vec[1] = " 0  0  1";
  732.    %vec[2] = " 0  0 -1";
  733.    %vec[3] = " 1  0  0";
  734.    %vec[4] = "-1  0  0";
  735.    %impulseVec  = "0 0 0";
  736.    %vec[0] = MatrixMulVector( %obj.getTransform(), %vec[0]);
  737.  
  738.    // Make sure the point is valid
  739.    %pos = "0 0 0";
  740.    %numAttempts = 5;
  741.    %success     = -1;
  742.    for (%i = 0; %i < %numAttempts; %i++) {
  743.       %pos = VectorAdd(%oldPos, VectorScale(%vec[%i], 3));
  744.       if (%obj.checkDismountPoint(%oldPos, %pos)) {
  745.          %success = %i;
  746.          %impulseVec = %vec[%i];
  747.          break;
  748.       }
  749.    }
  750.    if (%forced && %success == -1)
  751.       %pos = %oldPos;
  752.  
  753.    %obj.mountVehicle = false;
  754.    %obj.schedule(4000, "mountVehicles", true);
  755.    
  756.    // Unmount from node, and give player control.
  757.    %obj.unMount();
  758.    %this.onUnMount(%obj);
  759.    %obj.setControlObject(%obj);   
  760.  
  761.    // Position above dismount point
  762.    %obj.setTransform(%pos);
  763.    %obj.applyImpulse(%pos, VectorScale(%impulseVec, %obj.getDataBlock().mass));
  764. }
  765.  
  766.  
  767. //----------------------------------------------------------------------------
  768.  
  769. function Armor::onCollision(%this,%obj,%col)
  770. {
  771.    if (%obj.getState() $= "Dead")
  772.       return;
  773.  
  774.    // Try and pickup all items
  775.    if (%col.getClassName() $= "Item") {
  776.       %obj.pickup(%col);
  777.       return;
  778.    }
  779.  
  780.    // Mount vehicles
  781.    if (%col.getDataBlock().className $= WheeledVehicleData && %obj.mountVehicle &&
  782.          %obj.getState() $= "Move" && %col.mountable) {
  783.  
  784.       // Only mount drivers for now.
  785.       %node = 0;
  786.       %col.mountObject(%obj,%node);
  787.       %obj.mVehicle = %col;
  788.    }
  789. }
  790.  
  791. function Armor::onImpact(%this, %obj, %collidedObject, %vec, %vecLen)
  792. {
  793.    %obj.damage(0, VectorAdd(%obj.getPosition(),%vec),
  794.       %vecLen * %this.speedDamageScale, "Impact");
  795. }
  796.  
  797.  
  798. //----------------------------------------------------------------------------
  799.  
  800. function Armor::damage(%this, %obj, %sourceObject, %position, %damage, %damageType)
  801. {
  802.    if (%obj.getState() $= "Dead")
  803.       return;
  804.    %obj.applyDamage(%damage);
  805.    %location = "Body";
  806.  
  807.    // Deal with client callbacks here because we don't have this
  808.    // information in the onDamage or onDisable methods
  809.    %client = %obj.client;
  810.    %sourceClient = %sourceObject ? %sourceObject.client : 0;
  811.  
  812.    if (%obj.getState() $= "Dead")
  813.       %client.onDeath(%sourceObject, %sourceClient, %damageType, %location);
  814. }
  815.  
  816. function Armor::onDamage(%this, %obj, %delta)
  817. {
  818.    // This method is invoked by the ShapeBase code whenever the 
  819.    // object's damage level changes.
  820.    if (%delta > 0 && %obj.getState() !$= "Dead") {
  821.  
  822.       // Increment the flash based on the amount.
  823.       %flash = %obj.getDamageFlash() + ((%delta / %this.maxDamage) * 2);
  824.       if (%flash > 0.75)
  825.          %flash = 0.75;
  826.       %obj.setDamageFlash(%flash);
  827.  
  828.       // If the pain is excessive, let's hear about it.
  829.       if (%delta > 10)
  830.          %obj.playPain();
  831.    }
  832. }
  833.  
  834. function Armor::onDisabled(%this,%obj,%state)
  835. {
  836.    // The player object sets the "disabled" state when damage exceeds
  837.    // it's maxDamage value.  This is method is invoked by ShapeBase
  838.    // state mangement code.
  839.  
  840.    // If we want to deal with the damage information that actually
  841.    // caused this death, then we would have to move this code into
  842.    // the script "damage" method.
  843.    %obj.playDeathCry();
  844.    %obj.playDeathAnimation();
  845.    %obj.setDamageFlash(0.75);
  846.  
  847.    // Release the main weapon trigger
  848.    %obj.setImageTrigger(0,false);
  849.  
  850.    // Schedule corpse removal.  Just keeping the place clean.
  851.    %obj.schedule($CorpseTimeoutValue - 1000, "startFade", 1000, 0, true);
  852.    %obj.schedule($CorpseTimeoutValue, "delete");
  853. }
  854.  
  855.  
  856. //-----------------------------------------------------------------------------
  857.  
  858. function Armor::onLeaveMissionArea(%this, %obj)
  859. {
  860.    // Inform the client
  861.    %obj.client.onLeaveMissionArea();
  862. }
  863.  
  864. function Armor::onEnterMissionArea(%this, %obj)
  865. {
  866.    // Inform the client
  867.    %obj.client.onEnterMissionArea();
  868. }
  869.  
  870. //-----------------------------------------------------------------------------
  871.  
  872. function Armor::onEnterLiquid(%this, %obj, %coverage, %type)
  873. {
  874.    switch(%type)
  875.    {
  876.       case 0: //Water
  877.       case 1: //Ocean Water
  878.       case 2: //River Water
  879.       case 3: //Stagnant Water
  880.       case 4: //Lava
  881.          %obj.setDamageDt(%this, $DamageLava, "Lava");
  882.       case 5: //Hot Lava
  883.          %obj.setDamageDt(%this, $DamageHotLava, "Lava");
  884.       case 6: //Crusty Lava
  885.          %obj.setDamageDt(%this, $DamageCrustyLava, "Lava");
  886.       case 7: //Quick Sand
  887.    }
  888. }
  889.  
  890. function Armor::onLeaveLiquid(%this, %obj, %type)
  891. {
  892.    %obj.clearDamageDt();
  893. }
  894.  
  895.  
  896. //-----------------------------------------------------------------------------
  897.  
  898. function Armor::onTrigger(%this, %obj, %triggerNum, %val)
  899. {
  900.    // This method is invoked when the player receives a trigger
  901.    // move event.  The player automatically triggers slot 0 and
  902.    // slot one off of triggers # 0 & 1.  Trigger # 2 is also used
  903.    // as the jump key.
  904. }
  905.  
  906.  
  907. //-----------------------------------------------------------------------------
  908. // Player methods
  909. //-----------------------------------------------------------------------------
  910.  
  911. //----------------------------------------------------------------------------
  912.  
  913. function Player::kill(%this, %damageType)
  914. {
  915.    %this.damage(0, %this.getPosition(), 10000, %damageType);
  916. }
  917.  
  918.  
  919. //----------------------------------------------------------------------------
  920.  
  921. function Player::mountVehicles(%this,%bool)
  922. {
  923.    // If set to false, this variable disables vehicle mounting.
  924.    %this.mountVehicle = %bool;
  925. }
  926.  
  927. function Player::isPilot(%this)
  928. {
  929.    %vehicle = %this.getObjectMount();
  930.    // There are two "if" statements to avoid a script warning.
  931.    if (%vehicle)
  932.       if (%vehicle.getMountNodeObject(0) == %this)
  933.          return true;
  934.    return false;
  935. }
  936.  
  937.  
  938. //----------------------------------------------------------------------------
  939.  
  940. function Player::playDeathAnimation(%this)
  941. {
  942.    if (%this.deathIdx++ > 11)
  943.       %this.deathIdx = 1;
  944.    %this.setActionThread("Death" @ %this.deathIdx);
  945. }
  946.  
  947. function Player::playCelAnimation(%this,%anim)
  948. {
  949.    if (%this.getState() !$= "Dead")
  950.       %this.setActionThread("cel"@%anim);
  951. }
  952.  
  953.  
  954. //----------------------------------------------------------------------------
  955.  
  956. function Player::playDeathCry( %this )
  957. {
  958.    %this.playAudio(0,DeathCrySound);
  959. }
  960.  
  961. function Player::playPain( %this )
  962. {
  963.    %this.playAudio(0,PainCrySound);
  964. }
  965.